#include <bits/stdc++.h>
// 2025/06/11
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

#define int long long
const int N = 1000001;
int n, s[N], f[N];
vector<int> edge[N];

void dfs(int u, int fa){
    for (auto v : edge[u]){
        if (v == fa) continue;
        dfs(v, u);
        s[u] += s[v];
    }
    s[u]++;
}

void dfs2(int u, int fa){
    for (auto v : edge[u]){
        if (v == fa) continue;
        f[v] = f[u] + n - 2 * s[v];
        dfs2(v, u);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1, 0);
    dfs2(1, 0);
    int m = INT_MIN, id = 0;
    for (int i = 1; i <= n; i++)
        if (f[i] > m)
            m = f[i], id = i;
    cout << id << endl;  
    return 0;
}